const Mock = require('mockjs')
const body = require('body-parser')
function registerRouters(app){
  // 定义使用json格式的传参数据
  app.use(body.json())
  return routers = [
    {
      url: '/url/path',
      method: 'post',
      response: (req, res) => {
        console.log(req.body) // 拿到post传参
        res.json(Mock.mock({
          status: 1,
          data: '请求接口/url/path'
        }))
      }
    },
    {
      url: '/user/list',
      method: 'get',
      response: (req, res) => {
        res.json(Mock.mock({
          status: 1,
          total: 30,
          "list|10": [{
            "id|+1": 1,
            "name": "@cname",
            "age|1-100": 10,
            "job|1": ["学生", "上班族", "自由工作者", "商人", "演员"]
          }]
        }))
      }
    }
  ]
}
module.exports = registerRouters